package com.wngbms.redisson;

import com.wngbms.redisson.bean.DemoBean;
import org.redisson.Redisson;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import org.redisson.codec.JsonJacksonCodec;
import org.redisson.config.Config;
import org.redisson.config.TransportMode;

import java.util.UUID;

public class RedissonClientSimpleDemo {

    public static void main(String[] args) throws InterruptedException {

        Config config = new Config();

        config.setTransportMode(TransportMode.NIO);
        config.useSingleServer().setAddress("redis://127.0.0.1:6379");
        config.setCodec(new JsonJacksonCodec());
        config.setNettyThreads(4);

        RedissonClient redisson = Redisson.create(config);

        redisson.getBucket("buck").set(UUID.randomUUID().toString());

        while (true) {

            RBucket<DemoBean> buck = redisson.getBucket("buck");
            System.out.println(buck.get());

            Thread.sleep(500);
        }
    }

}
